//
//  FPWillSaleViewController.m
//  BSLCar
//
//  Created by 梁毅 on 15/5/23.
//  Copyright (c) 2015年 lyz. All rights reserved.
//

#import "FPWillSaleViewController.h"

@interface FPWillSaleViewController ()

@end

@implementation FPWillSaleViewController
- (void)dealloc
{
    [_dataArray release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] init];
    item.title = @"返回";
    self.navigationItem.backBarButtonItem = item;
    [item release];
    
    self.navigationItem.title = @"即将开售";

    tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64) style:UITableViewStylePlain];
    tableview.separatorStyle = UITableViewCellSelectionStyleDefault;

    tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    

    FirstPageWillSaleRequest *re = [[FirstPageWillSaleRequest alloc]init];
    tableview.separatorColor = [UIColor clearColor];
    //初始化数组
    self.dataArray = [re getParserResult];
    
    tableview.delegate = self;
    tableview.dataSource = self;
    
    
    [self.view addSubview:tableview];
    [self.navigationItem.rightBarButtonItem release];
    [tableview release];
    [re  release];
    // Do any additional setup after loading the view.
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    FirstPageWillSaleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    if (cell == nil) {
        cell = [[FirstPageWillSaleTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }
    //从数组里面取出来的model
 //    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    FPWillSaleModel *model =[self.dataArray objectAtIndex:indexPath.row];

    cell.labelName.text = model.name;
    cell.labelDate.text = model.selltime;
    cell.labelPrice.text = model.price;

    cell.buttonMessage.text = model.newstitle;
    cell.buttonMessage.textColor = [UIColor blueColor];

    NSString *str = model.imgurl;

    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
   // NSLog(@"%@", url);
    [cell.mimgeview sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"Bei"]];
    
    cell.label.backgroundColor = [UIColor grayColor];
    cell.label.alpha = 0.3;
    return cell;
}

- (void)dianji
{
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     FPWillSaleModel *model =[self.dataArray objectAtIndex:indexPath.row];
    InformationViewController *ifv = [[InformationViewController alloc]init];
    ifv.str = model.newsurl;
    [self.navigationController pushViewController:ifv  animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
